package gtkwire.widget;

import gtkwire.*;
import gtkwire.widget.utils.GtkShadow;

/**
*A bin with a decorative frame and optional label.
*/
public class GtkFrame extends GtkBin
{
	protected String label;
	
        public GtkFrame( String label )
        {
		super();
		this.widgetType = WT_GtkFrame;
		this.label = label;
		gtkCreate();
        }

        public GtkFrame( String name, GladeKey key )
        {
		super( name, key );
		this.widgetType = WT_GtkFrame;
        }
	
	/**
	*Sets the text of the label.
	*/
	public void setLabel( String labelText )
	{
		app().sendCommand( name, GTKWireCommand.SET_LABEL, labelText );
	}

	/**
	* Data necessery for object creation.
	*/
	protected String[] getCreateData()
	{
		String[] msg = { label };
		return msg;
	}

	/**
	*Sets the alignment of the frame widget's label. The default values for a newly created frame are 0.0 and 0.5.
	*@param xalign The position of the label along the top edge of the widget. 
	*A value of 0.0 represents left alignment; 1.0 represents right alignment.
	*@param yalign 	The y alignment of the label. A value of 0.0 aligns under the frame; 1.0 aligns above the frame.
	*If the values are exactly 0.0 or 1.0 the gap in the frame won't be painted because the label will be completely above or below the frame.
	*/
	public void setLabelAlignment( double xalign, double yalign )
	{
		double[] data = new double[ 2 ];
		data[ 0 ] = xalign;
		data[ 1 ] = yalign;
		app().sendCommand( name, GTKWireCommand.SET_ALIGNMENT, data );
	}

	public void setShadow( GtkShadow shadow )
	{
		app().sendCommand( name, GTKWireCommand.SET_SHADOW, shadow.getMode() );
	}

	public GtkLabel getLabelWidget()
	{
		//--- Creates a widget and puts it in native table.
		GtkLabel addLabel = new GtkLabel();
		//--- Gets REAL widget and places it INSTEAD of created one 
		//--- in the table with the created name.
		app().sendCommand( name,  GTKWireCommand.EXTRACT_LABEL, addLabel.getName() );
		return addLabel;
	}

}//end class